package ac.svn.accesscontrol.store;

import java.util.HashSet;
import java.util.Set;

public class SVNUser implements Comparable<SVNUser>,ISVNItem
{
	private String userAlias;
	private String userName;
	private Set<String> groups;
	
	public String getUserAlias() {
		return userAlias;
	}
	public void setUserAlias(String userAlias) {
		this.userAlias = userAlias;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public Set<String> getGroups() {
		return groups;
	}
	public void setGroups(Set<String> groups) {
		this.groups = groups;
	}
	
	public void addGroup(String groupId)
	{
		this.groups.add(groupId);
	}
	
	public boolean isMemberOfGroup(String groupId)
	{
		if(this.groups.contains(groupId))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	public SVNUser(String userAlias, String userName) {
		super();
		this.userAlias = userAlias;
		this.userName = userName;
		this.groups = new HashSet<String>();
	}
	
	public SVNUser() {
		super();
		this.groups = new HashSet<String>();
	}
	@Override
	public String toString() {
		return "<HTML><b>" + userAlias + "</b> [ " + userName +" ]" ;
	}
	@Override
	public int compareTo(SVNUser o) {
		return userAlias.compareTo(o.getUserAlias());
	}
	@Override
	public String getName() {
		return getUserName();
	}
	@Override
	public String getTooltipText() {
		return "<HTML>SVNUser<br>UserAlias=" + userAlias + "<br>UserName=" + userName
		+ "<br>Groups=" + groups + "</HTML>";
	}
	
	
	
}
